﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;

namespace Repository
{
    public class ID535
    {
        public static string getProfileName()
        {
            return getByKeyword("ProfileName");
        }

        public static string getGraphName()
        {
            return getByKeyword("GraphName");
        }

        public static string getGraphType()
        {
            return getByKeyword("GraphType");
        }

        public static string getGraphDateRange()
        {
            return getByKeyword("GraphDateRange");
        }

        private static string getByKeyword(string strKeyword)
        {
            //Read configuration from file
            DataTable dtTestData = new DataTable();
            dtTestData.Columns.Add(new DataColumn("Column0", typeof(string)));
            string strFilenameFullPath = Utilities.GlobalFolder.REPOSITORY_TESTDATA + "ID535.csv";

            if (File.Exists(strFilenameFullPath))
            {
                dtTestData = Utilities.DataTableUtil.buildDataTableFromFile(strFilenameFullPath);
            }

            //Set to run
            foreach (DataRow DR in dtTestData.Rows)
            {
                string strKeyWord = DR[0].ToString();
                if (strKeyWord.Equals(strKeyword))
                    return DR[1].ToString();
            }

            return null;
        }
    }

    public class ID1433
    {
        public static string getListOfCategoies()
        {
            string strListCategories = "";
            //Read configuration from file
            DataTable dtTestData = new DataTable();
            dtTestData.Columns.Add(new DataColumn("Column0", typeof(string)));
            string strFilenameFullPath = Utilities.GlobalFolder.REPOSITORY_TESTDATA + "ID1433.csv";

            if (File.Exists(strFilenameFullPath))
            {
                dtTestData = Utilities.DataTableUtil.buildDataTableFromFile(strFilenameFullPath);
            }

            //Set to run
            foreach (DataRow DR in dtTestData.Rows)
            {
                strListCategories += DR[0].ToString() + ",";
            }

            return strListCategories;
        }

        public static string getItemsOfCate(string strCate)
        {
            string strListItems = "";
            //Read configuration from file
            DataTable dtTestData = new DataTable();
            dtTestData.Columns.Add(new DataColumn("Column0", typeof(string)));
            string strFilenameFullPath = Utilities.GlobalFolder.REPOSITORY_TESTDATA + strCate + ".csv";

            if (File.Exists(strFilenameFullPath))
            {
                dtTestData = Utilities.DataTableUtil.buildDataTableFromFileDictionary(strFilenameFullPath);
            }

            //Set to run
            foreach (DataRow DR in dtTestData.Rows)
            {
                strListItems += DR[0].ToString() + ",";
            }

            return strListItems;
        }

        public static string getAllSandBoxes(string strSandBox)
        {
            string strListItems = "";
            //Read configuration from file
            DataTable dtTestData = new DataTable();
            dtTestData.Columns.Add(new DataColumn("Column0", typeof(string)));
            string strFilenameFullPath = Utilities.GlobalFolder.REPOSITORY_TESTDATA + strSandBox + ".csv";

            if (File.Exists(strFilenameFullPath))
            {
                dtTestData = Utilities.DataTableUtil.buildDataTableFromFileDictionary(strFilenameFullPath);
            }

            //Set to run
            foreach (DataRow DR in dtTestData.Rows)
            {
                strListItems += DR[0].ToString() + ",";
            }

            return strListItems;
        }
    }
}
